package com.fccommunity.base;

import android.os.Bundle;

import com.amap.api.maps2d.AMap;
import com.amap.api.maps2d.MapView;

/**
 * Created by Administrator on 2015/9/15.
 */
public abstract class BaseMapActivity extends BaseActivity {
    protected MapView mapView;
    protected AMap aMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getRootViewRes());
        initView();
        mapView = getMapView();
        mapView.onCreate(savedInstanceState);// 此方法必须重写
        initMap();
    }

    protected abstract void initView();

    protected abstract int getRootViewRes();

    protected void initMap() {
        aMap = mapView.getMap();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mapView.onSaveInstanceState(outState);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mapView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mapView.onPause();
    }

    @Override
    protected void onDestroy() {
        mapView.onDestroy();
        aMap=null;
        super.onDestroy();

    }

    protected abstract MapView getMapView();

}
